$(function () {
    $("#head").load("/html/head.html");
    $("#foot").load("/html/foot.html");
    seletMain();
})

function seletMain() {
    let data = myAjax('/main', '', 'get');
    let mainPagelist = data.mainPagelist;
    let productClassifylist = data.productClassifylist;
    let newslist = data.newslist;
    let list = data.list;
    console.log(mainPagelist);
    // 第二部分
//第二部分 的 产品的点击
    if (mainPagelist[0].isshow=="是"){
        let model2 = '';
        model2 += '<div class="text-1">' + mainPagelist[0].title + '</div>\n' +
            '     <div class="text-2">' + mainPagelist[0].englishName + '</div>';
        $("#main-2-01").html(model2);
        let html1 = '';
        for (let i = 0; i < productClassifylist.length; i++) {
            html1 += '<div><div onclick="selectProduct('+i+')" class="zi" >' + productClassifylist[i].name + '</div></div>';
        }
        let a = "/html/message.html"
        html1 += '<div><div onclick="message()">在线留言</div></div>\n' +
            '   <div><div>全国预约热线：400-789-123"</div></div>';
        $("#main-2-02-left").html(html1);
        $("#MOKE").html("MOKE+");
    }else {
        let model2 = '';
        $("#main-2").html(model2);
        $("#main-2").css("height","0px");
    }
    //第三部分
    if (mainPagelist[1].isshow=="是"){
        let model3 = '';
        model3 += '<div class="text-1">' + mainPagelist[1].title + '</div>\n' +
            '     <div class="text-2">' + mainPagelist[1].englishName + '</div>';
        $("#main-3-01").html(model3);
    }else {
        let model3 = '';
        $("#main-3").html(model3);
        $("#main-3").css("height","0px");
    }

//第四部分
    if (mainPagelist[2].isshow=="是"){
        let model4 = '';
        model4 += '<div class="text-1">' + mainPagelist[2].title + '</div>\n' +
            '     <div class="text-2">' + mainPagelist[2].englishName + '</div>';
        $("#main-4-01").html(model4);
        let html2 = '';
        for (let i = 0; i < 3; i++) {
            html2 += '<div>\n' +
                '       <div class="main-4-right-date">\n' +
                '         <div>' + newslist[i].dateRi + '</div>\n' +
                '          <div>' + newslist[i].dateTian + '</div>\n' +
                '            </div>\n' +
                '           <div class="main-4-right-words">\n' +
                '           <div><a href="' + list[3].href + '">' + newslist[i].title + '</a></div>\n' +
                '           <div>\n' +
                '              ' + newslist[i].content + '\n' +
                '           </div>\n' +
                '           </div>\n' +
                '      </div>'
        }
        html2 += '<div>\n' +
            '      <div><a href="' + list[3].href + '">></a></div>\n' +
            '     <div><a href="' + list[3].href + '">阅读更多新闻</a></div>\n' +
            '      </div>';
        $("#main-4-right").html(html2);
    }else {
        let model4 = '';
        $("#main-4").html(model4);
        $("#main-4").css("height","0px");
    }

    // //是否展示===========================
    // let model = '';

}
function selectProduct(i) {
    window.location.href="/html/product.html";
    let n = i+1;
    localStorage.setItem("main-product",n);
}
function message() {
    window.location.href="/html/message.html";
}